package com.design.mode.iterator;

/**
 * Created by lucky on 2018/9/13.
 */
public class BookShelf extends Aggregate {

    private Book[] books;

    private int last;

    public BookShelf(int maxSize){
        this.books = new Book[maxSize];
    }

    public Book getBook(int index){
        return books[index];
    }

    public void appendBook(Book book){
        books[last] = book;
        last++;
    }

    public int getLength(){
        return books.length;
    }


    @Override
    public Iterator iterator() {
        return new BookShelfIterator(this);
    }
}
